package com.xiaoq.sites.repository.impl;

import java.util.List;

import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.xiaoq.sites.entity.SitesAnnouncementEntity;
import com.xiaoq.sites.repository.ISitesAnnouncementRepository;

@Repository
public class SitesAnnouncementRepositoryImpl implements ISitesAnnouncementRepository {
	
	@Autowired
	private Datastore datastore;

	@Override
	public SitesAnnouncementEntity findById(String id) {
		return datastore.get(SitesAnnouncementEntity.class, id);
	}

	@Override
	public List<SitesAnnouncementEntity> findBySitesId(String sitesId) {
		Query<SitesAnnouncementEntity> sitesAnnouncementQuery = datastore.find(SitesAnnouncementEntity.class);
		sitesAnnouncementQuery.field("sitesId").equal(sitesId);
		return sitesAnnouncementQuery.asList();
	}


}
